const { get_map, update_map} = require("../controller/map");
const { SuccessModel, ErrorModel } = require("../model/resModel");
var express = require("express");
var router = express.Router();



router.get("/get_map", function (req, res, next) {
  const result = get_map();
  return result.then((val) => {
    res.json(new SuccessModel(val));
  });
});

router.post("/update_map", function (req, res, next) {
  const result = update_map(req.query.id, req.body);
  return result.then((val) => {
    if (val) {
      res.json(new SuccessModel());
    } else {
      res.json(new ErrorModel("更新失败"));
    }
  });
});


module.exports = router;
